/**
 * @param {number[]} prices
 * @return {number}
 */
var maxProfit = function(prices) {
    let min = 100000,
    result = 0;

    for(let i = 0;i<prices.length;i++){
        if(prices[i]-min>result){
            result = prices[i]-min
        }
        if(prices[i] < min){
            min = prices[i]
        }
    }
    return result
};

